'use strict';

import { Service } from 'egg'

export default class TemplatePageService extends Service {

  async all() {
    const { TemplatePage } = this.ctx.model as any;
    return TemplatePage.findAll()
  }

  async create(data) {
    const { TemplatePage } = this.ctx.model as any;
    await new TemplatePage({
      ...data,
      createTime: new Date(),
    }).save()
  }

  async update(id, data) {
    const { TemplatePage } = this.ctx.model as any;
    await TemplatePage.updateWithId(id, data)
  }

  async remove(id) {
    const { TemplatePage } = this.ctx.model as any;
    await TemplatePage.removeWithId(id)
  }
}